import {createRouter, createWebHistory} from "vue-router";

// 创建路由器对象
const router = createRouter({
    // 使用 createWebHistory 函数创建 Web 历史记录
    history: createWebHistory(),
    // 定义路由
    routes: [
        {
            // 路径为“/”的路由
            path: '/',
            // 组件为从 '../view/LoginView.vue' 导入的组件
            component: () => import('../view/LoginView.vue'),
        },
        {
            // 路径为“/dashboard”的路由
            path: '/dashboard',
            // 组件为从 '../view/DashboardView.vue' 导入的组件
            component: () => import('../view/DashboardView.vue'),
            //子路由
            children: [
                {
                    path: '',
                    component: () => import('../view/StatisticView.vue')
                },

                {
                    // 子路由不能以/开头
                    path: 'user',
                    component: () => import('../view/UserView.vue')
                },

                {
                    //id为动态变量
                    path: 'user/:id',
                    component: () => import('../view/UserDetail.vue')
                },

                {
                    path: 'activity',
                    component: () => import('../view/ActivityView.vue')
                },

                {
                    path: 'activity/add',
                    component: () => import('../view/ActivityRecordView.vue')
                },

                {
                    path: 'activity/edit/:id',
                    component: () => import('../view/ActivityRecordView.vue')
                },

                {
                    path: 'activity/:id',
                    component: () => import('../view/ActivityDetailView.vue')
                },

                {
                    path: 'clue',
                    component: () => import('../view/ClueView.vue')
                },

                {
                    path: 'clue/add',
                    component: () => import('../view/ClueRecordView.vue')
                },

                {
                    path: 'clue/edit/:id',
                    component: () => import('../view/ClueRecordView.vue')
                },

                {
                    path: 'clue/detail/:id',
                    component: () => import('../view/ClueDetailView.vue')
                },

                {
                    path: 'customer',
                    component: () => import('../view/CustomerView.vue')
                },

                {
                    path: 'customer/detail/:id',
                    component: () => import('../view/CustomerDetailView.vue')
                },
                {
                    path: 'tran',
                    component: () => import('../view/TransactionView.vue')
                },
                {
                    path: 'tran/detail/:id',
                    component: () => import('../view/TransactionDetailView.vue')
                },
                {
                    path: 'product',
                    component: () => import('../view/ProductView.vue')
                },
                {
                    path: 'dictype',
                    component: () => import('../view/DictypeView.vue')
                },
                {
                    path: 'dicvalue',
                    component: () => import('../view/DicvalueView.vue')
                }
            ]
        },

    ]
})

// 导出路由器对象
export default router;